package com.briup.pts.web.controller;

import com.briup.pts.config.response.Result;
import com.briup.pts.domain.bean.Log;
import com.briup.pts.service.LogService;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.Min;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Validated
@Tag(name = "日志模块")
@RestController
@RequestMapping("/log")
@RequiredArgsConstructor
public class LogController {

    private final LogService logService;

    @Operation(summary = "分页查询日志信息接口")
    @GetMapping("/page")
    public Result<PageInfo<Log>> pageQuery(
            @RequestParam(defaultValue = "1")
            @Min(value = 1, message = "当前页码不能小于1") Integer pageNum,
            @RequestParam(defaultValue = "5")
            @Min(value = 1, message = "页面不能小于1") Integer pageSize,
            String originIp
    ){
        PageInfo<Log> pageInfo = logService.pageQuery(pageNum, pageSize, originIp);
        return Result.success(pageInfo);
    }
}
